﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsServicesByGetRoleInfo
{
    public class SqlUtil
    {
        public static string ConnString = System.Configuration.ConfigurationManager.ConnectionStrings["Default"].ToString();
        public static void Save(RoleInfo info)
        {

            using (SqlConnection conn = new SqlConnection(ConnString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = @"INSERT INTO dbo.Services_InsertData
                                                 (SysRolesID,
                                                   RolesName,
                                                   CreateDate,
                                                   ModifyDate,
                                                   Enable
                                                 )

                                         VALUES(" + info.SysRolesID + @",
                                                   N'" + info.RolesName + @"', 
                                                   '" + info.CreateDate + @"',
                                                   '" + info.ModifyDate + @"', 
                                                   " + info.Enable + @"
                                                 )";
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.Connection = conn;
                    cmd.ExecuteNonQuery();
                }
            }
        }
    }
}
